import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import { useDark } from '@vueuse/core'

useDark()
const app = createApp(App)
const pinia = createPinia()

// 先安装pinia
app.use(pinia)

// 然后初始化用户状态
import { useUserStore } from './stores/user'
const userStore = useUserStore()
userStore.initUserState()

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.use(router).use(ElementPlus).mount('#app')